<%@ page import="com.ld.manageBook.service.BorrowService" %>
<%@ page import="com.ld.manageBook.service.impl.BorrowImpl" %>
<%@ page import="com.ld.manageBook.bean.User" %>
<%@ page import="com.ld.manageBook.bean.Borrow" %>
<%@ page import="java.util.List" %>
<%@ page import="com.ld.manageBook.bean.Books" %>
<%@ page import="com.ld.manageBook.service.BookService" %>
<%@ page import="com.ld.manageBook.service.impl.BookServiceImpl" %><%--
  Created by IntelliJ IDEA.
  User: 刘邓
  Date: 2023-06-02
  Time: 10:58
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>还书</title>
</head>
<body>
<%!
    private BorrowService borrowService = new BorrowImpl();
	private BookService bookService = new BookServiceImpl();
	private Books book;
	private String bookName;
%>
<%
    User user = (User)(session.getAttribute("user"));
    List<Borrow> borrows = borrowService.getBorrowBookByUserName(user.getUsername());
    out.println("<table style='width:60%;height:400px;margin:0 auto; border:1px solid #ccc;cellspacing:0; cellpadding:0'>" +
            "<tr>" +
            "<th>书名</th>" +
            "<th>时间</th>" +
            "<th>数量</th>" +
            "<th>未还量</th>" +
            "<th>还书</th>" +
            "</tr>");
    for (Borrow borrow : borrows) {
        String returnDOM = "<td><a href=" + "'/home/returnBookDisplay.jsp?id=" + borrow.getId() + "'>还书" + "</a></td>";
		book = bookService.getBookById(borrow.getBook_id());
        out.println("<tr>");
        out.println("<td style='text-align:center'>" + book.getName() + "</td>");
        out.println("<td style='text-align:center'>" + borrow.getTime() + "</td>");
        out.println("<td style='text-align:center'>" + borrow.getNumber() + "</td>");
        out.println("<td style='text-align:center'>" + borrow.getNeedreturn() + "</td>");
        out.println(returnDOM);
        out.println("</tr>");
    }
    out.println("</table>");

%>
</body>
</html>
